package com.kstech.mp3604.data.typeConvert

import androidx.room.TypeConverter
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.kstech.mp3604.bean.BoxCoordinate
import java.lang.reflect.Type

/**
 * author: blankii
 * created on: 2025/4/23 15:10
 * description:
 */
class BoxCoordinateListTypeConvert {
    private val gson = Gson()

    @TypeConverter
    fun objectToString(list: List<BoxCoordinate>?): String? {
        return gson.toJson(list)
    }

    @TypeConverter
    fun stringToObject(json: String?): List<BoxCoordinate>? {
        if (json == null) return null
        val listType: Type = object : TypeToken<List<BoxCoordinate>>() {}.type
        return gson.fromJson(json, listType)
    }
}